using SF.Code.Extension.ComputerLanguages;
using SG.Lang.Dry.Base;
using SG.Lang.Dry.Controlling;
using SG.Lang.Dry.Mirrors;

namespace SG.Lang.Dry.Code
{
    public class Loop : Expression
    {
        private readonly Expression _while;

        private readonly Expression _do;

        private readonly bool _atLeastOnce;

        protected Loop(ref ElementRecord elementRecord, ref ExpressionRecord expressionRecord)
            : base(ref elementRecord, ref expressionRecord)
        {
            _while = expressionRecord.Value.ResolveExpression();

            _do = expressionRecord.Left.ResolveExpression();

            _atLeastOnce = elementRecord.Kind == ElementKind.DoWhile;
        }

        public Expression While { get { return _while; } }

        public Expression Do { get { return _do; } }

        public bool AtLeastOnce { get { return _atLeastOnce; } }
    }
}